﻿using Pathfinding.RVO;
using UnityEngine;
using Yoozoo.Gameplay.Liberty.AI;

namespace Yoozoo.Gameplay.Liberty.PlayerController
{
    [RequireComponent(typeof(RVOController))]
    public class ManualRVOAgent : MonoBehaviour {
        RVOController rvo;

        public float speed = 1;
        void Awake () {
            rvo = GetComponent<RVOController>();
        }

        void Update ()
        {
            var playerInput = LibertyAIUtils.PlayerController.inputController.playInput;
            var x = playerInput.HorRealValue;
            var y = playerInput.VerRealValue;

            var v = new Vector3(x, 0, y) * speed;

            // Override the RVOController's velocity. This will disable local avoidance calculations for one simulation step.
            rvo.velocity = v;
        }
    }
}